package com.shujia.wyh.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

public class MySqlTool {
    private static PreparedStatement prep;

    private MySqlTool(){}

    /**
     *     url: jdbc:mysql://192.168.254.150:3306/bigdata19?useUnicode=true&characterEncoding=utf8&useSSL=false
     *     username: root
     *     password: 123456
     * @return
     */
    public static PreparedStatement getConnection(String sql){

        String url = "jdbc:mysql://192.168.254.150:3306/bigdata19?useUnicode=true&characterEncoding=utf8&useSSL=false";
        String username= "root";
        String password = "123456";

        //加载驱动
        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection conn = DriverManager.getConnection(url, username, password);
            prep = conn.prepareStatement(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return prep;
    }
}
